<?php
class DefaultModule extends CWebModule{

	public static $info = array(
			'name'=>'Default',
			'description'=>'The module was first called as default',
			'version'=>'1.0'
		);
	private $_isMobile;
	const RE_MOBILE='/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i';

	public function getIsMobile()
	{
	    if ($this->_isMobile===null)
	        $this->_isMobile=isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']) ||
	            preg_match(self::RE_MOBILE, $_SERVER['HTTP_USER_AGENT']);
	    return $this->_isMobile;
	}
	public function init()
	{
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		
		$this->setImport(array(
			'default.models.*',
			'default.components.*',
		));
		$this->getIsMobile();
		if($this->isMobile){
		Yii::app()->theme = 'mobile';
		}
	}
	
	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
	
	public function install(){
	
	}
	
	public function uninstall(){
	
	}
}